<template>
  <div>
    <div class="mantle"></div>
    <div class="wrap">
      <div class="title">{{ title }}</div>
      <div class="text">
        <p v-html="sanitizedTitle"></p>
      </div>
      <div class="btn">
        <ep-button
          type="back"
          @click="$emit('close')"
          >返回</ep-button
        >
      </div>
    </div>
  </div>
</template>

<script>
import DOMPurify from 'dompurify';

export default {
  name: "reasonDialog",
  props: {
    title: {
      type: String,
      default: "驳回理由",
    },
    reason: {
      type: String,
      required: true,
    },
  },
  computed: {
    sanitizedTitle() {
      // 只允许特定安全标签（如<b><i>），过滤所有脚本
      return DOMPurify.sanitize(this.title, {
        ADD_TAGS: ['b', 'i'], // 允许的标签
        ADD_ATTR: ['class'] // 允许的属性
      });
    }
  },
  methods: {},
};
</script>

<style lang="scss" scoped>
.mantle {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.6);
}
.wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 570px;
  height: 460px;
  transform: translate(-50%, -50%);
  z-index: 1001;
  background: url("@/assets/img/small-dialog.svg") no-repeat;
  background-size: 570px 460px;
  .title {
    line-height: 48px;
    font-size: 16px;
    text-align: center;
    color: #fff;
  }
  .text {
    height: 312px;
    margin-top: 20px;
    padding: 0 40px;
    font-size: 16px;
    color: #fff;
    overflow: auto;
    p {
      line-height: 24px;
      text-indent: 32px;
    }
  }
  .btn {
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
    padding-right: 40px;
  }
}
</style>
